<!DOCTYPE html> <title>Basic Visual Test</title>

<style>
  @import '/reset.css';
  #reference {
    width: 200px;
    height: 200px;
    background-color: red;
    box-shadow: inset 0 0 0 1px black;
  }

  #popper {
    width: 100px;
    height: 100px;
    background-color: rebeccapurple;
    box-shadow: inset 0 0 0 1px black;
  }
</style>

<parent-element id="scroll">
  <div id="reference">Reference Box</div>
</parent-element>
<div id="popper">Popper Box</div>

<script type="module">
  class ParentElement extends HTMLElement {
    constructor() {
      super();
      this.attachShadow({ mode: 'open' });
      this.shadowRoot.innerHTML = this.template;
      this.scrollParent = this.shadowRoot.querySelector('#scroll');
    }
    get scrollTop() {
      return this.scrollParent.scrollTop;
    }
    set scrollTop(top) {
      this.scrollParent.scrollTop = top;
    }
    get template() {
      return `
                <style>
  @import '/reset.css';
                    :host {
                        display: block;
                    }
                    #scroll {
                        overflow: scroll;
                        width: 300px;
                        height: 300px;
                        background-color: grey;
                    }

                    #scroll::before {
                        content: 'before';
                        display: block;
                        height: 300px;
                        width: 1px;
                    }

                    #scroll::after {
                        content: 'after';
                        display: block;
                        height: 300px;
                        width: 1px;
                    }
                </style>
                <div id="scroll">
                    <slot></slot>
                </div>
            `;
    }
  }
  customElements.define('parent-element', ParentElement);
</script>

<script type="module">
  import { createPopper } from '../dist/popper.js';
  const reference = document.querySelector('#reference');
  const popper = document.querySelector('#popper');

  window.instance = createPopper(reference, popper, {
    placement: 'right',
  });
</script>
